<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace yiike\user\controllers;

use Yii;

/**
 * 接口修改密码
 *
            'new_password'     => Yii::t('user', 'New password'),
            'current_password' => Yii::t('user', 'Current password'),
 * @author Sylar
 */
class PasswordController extends \api\components\Controller {
    
    public function actionReset() {
        $data = Yii::$app->request->post();
        $passwordForm = new \yiike\user\models\PasswordForm();
        $passwordForm->setAttributes($data);
        if (! $passwordForm->save()) {
            $errors = array();
            foreach ($passwordForm->errors as $k => $v) {
                $errors[$k] = $v[0];
            }
            return ['code' => 100033, 'errors' => $errors];
        }
        return true;
    }
}
